package com.songlanyun.modules.order.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.songlanyun.common.utils.PageUtils;
import com.songlanyun.modules.order.dao.ChildOrderDao;
import com.songlanyun.modules.order.dao.ChildOrderServiceItemDao;
import com.songlanyun.modules.order.entity.ChildOrder;
import com.songlanyun.modules.order.entity.ChildOrderServiceItem;
import com.songlanyun.modules.order.service.ChildOrderService;
import com.songlanyun.modules.order.service.ChildOrderServiceItemService;
import com.songlanyun.modules.servicegoods.entity.ServiceItem;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


/**
 * 订单中的子订单的服务商品项目服务
 */
@Service("childOrderServiceItemService")
public class ChildOrderServiceItemServiceImpl  extends ServiceImpl<ChildOrderServiceItemDao, ChildOrderServiceItem> implements ChildOrderServiceItemService {

    @Override
    public List<ChildOrderServiceItem> loadServiceItem(Long childOrderId) {
        LambdaQueryWrapper<ChildOrderServiceItem> wrapper =  new LambdaQueryWrapper<>();
        wrapper.eq(ChildOrderServiceItem::getChildOrderId,childOrderId);
        return this.list(wrapper);
    }

    @Override
    public void branchCreate(Long childOrderId, List<ChildOrderServiceItem> list) {
        if(list.size()>0)
        {
            list.forEach(o->{
                o.setChildOrderId(childOrderId);
            });
            /**
             * 检测单品只能被一个sku关联 sku更改成共用
             list.stream().forEach(goodsSku -> {
             validateGoodsSkuSingleGoodsRepeat(goodsSku);
             });
             */
            this.saveBatch(list);
        }
    }

    @Override
    public ChildOrderServiceItem create(ChildOrderServiceItem entity) {
        return null;
    }

    @Override
    public ChildOrderServiceItem modify(ChildOrderServiceItem entity) {
        return null;
    }

    @Override
    public void remove(Long id) {

    }

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        return null;
    }
}
